﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Linq;

namespace Fastyou.Other.Consoles
{
    public static class ExtClass
    {
        public static XElement DirToXml(this DirectoryInfo dir)
        {

            XElement root = new XElement("Dir",
            new XAttribute("Name", dir.Name),
            from subDir in dir.GetDirectories()
            select subDir.DirToXml(),
            from file in dir.GetFiles()
            select new XElement("File", file.Name));
            return root;

        }
    }
}
